<template>
	<view>
		<view class="boxTop">
			<view class="box">
				<image :src="tx.head_img" mode=""></image>
				<text>{{tx.name}}</text>
			</view>
			<view class="jl" v-if="sf.user_type==1">
				<view class="jlbox">
					<view class="tu">
						<image src="../../static/jianli.png" mode=""></image>
					</view>
					<view class="zi">
						<text>我的简历</text>
						<text>简历完成度越高，有利于被企业录取</text>
						<text @click.stop="jl">点击完善简历</text>
					</view>
				</view>
			</view>
		</view>
		<view class="kong" v-if="sf.user_type==1"></view>
		<view class="content" v-if="sf.user_type==1">
			<u-cell-group>
				<u-cell-item @click="myInfo()" icon="order" title="个人资料"></u-cell-item>
				<u-cell-item @click="delivery()" icon="order" title="已投简历"></u-cell-item>
				<u-cell-item @click="intention()" icon="tags" title="求职意向">积极找工作</u-cell-item>
				<u-cell-item @click="yaoqingList()" icon="list-dot" title="邀请列表"></u-cell-item>
				<u-cell-item @click="mianshi()" icon="bookmark" title="企业邀请面试"></u-cell-item>
				<u-cell-item icon="lock" title="隐私设置"></u-cell-item>
				<u-cell-item @click='qh()' icon="account" title="切换身份">{{sf.user_type_name}}</u-cell-item>
				<u-cell-item @click='backLogin()' icon="warning" title="退出登录"></u-cell-item>
			</u-cell-group>
		</view>
		<view class="content" style="margin-top: 30rpx;" v-if="sf.user_type==2">
			<u-cell-group>
				<u-cell-item @click="cs()" icon="order" title="企业资料"></u-cell-item>
				<u-cell-item @click="position()" icon="file-text" title="职位管理"></u-cell-item>
				<u-cell-item @click="p2()" icon="email" title="简历管理"></u-cell-item>
				<u-cell-item icon="level" title="会员服务"></u-cell-item>
				<u-cell-item @click='qh()' icon="account" title="切换身份">{{sf.user_type_name}}</u-cell-item>
				<u-cell-item @click='backLogin()' icon="warning" title="退出登录"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				sf:'',
				tx:'',
				stateData:''
			}
		},
		onLoad() {
			let self=this;
			this.ff()
			
			uni.getStorage({
			    key: 'stateData',
			    success: function (res) {
			        self.stateData=res.data
					console.log(self.stateData,"静态数据")
			    }
			})
		},
		onShow() {
			this.ff()
			this.txxm()
			this.identity()
		},
		methods: {
			backLogin(){
				uni.showModal({
				    title: '温馨提示',
				    content: '确定退出登录吗？',
				    success: (res) => {
				        if (res.confirm) {
				            uni.removeStorage({
				                key: 'auth',
				                success: (res) => {
				                    uni.navigateTo({
				                    	url:'../login/login'
				                    })
				                }
				            });
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			myInfo(){
				uni.navigateTo({
					url:'../resume/portrait'
				})
			},
			delivery(){
				uni.navigateTo({
					url:'enterprise/delivery'
				})
			},
			intention(){
				uni.navigateTo({
					url:'enterprise/intention'
				})
			},
			yaoqingList(){
				uni.navigateTo({
					url:'enterprise/yaoqingList'
				})
			},
			position(){
				uni.navigateTo({
					url:'../index/zhiweiGuanli?id=1'
					// 1就是企业
				})
			},
			mianshi(){
				uni.navigateTo({
					url:'./company_invite_notice'
				})
			},
			async qh(){
				if(this.sf.user_type==1){
					// 普通用户切换企业
					const res=await this.post('/Index/User/be_company_user')
					if(res.code==200){
						this.sf.user_type_name='企业用户';
						this.sf.user_type=2;
					}
				}else{
					// 企业切换普通用户
					const res=await this.post('/Index/User/be_user')
					if(res.code==200){
						this.sf.user_type_name='普通用户';
						this.sf.user_type=1;
					}
				}
			},
			
			async txxm(){
				const res=await this.post('/Index/User/get_user_info')
				this.tx=res.data
			},
			async identity(){
				const res=await this.post('/Index/User/get_user_type')
				this.sf=res.data;
				uni.setStorage({
				    key: 'sf',
				    data: res.data,
				    success: function () {
				        console.log('success');
				    }
				});
				console.log(res)
			},
			jl(){
				uni.navigateTo({
					url:'../resume/resume'
				})
			},
			cs(){
				uni.navigateTo({
					url:'enterprise/enterprise'
				})
			},
			ff(){
				uni.getStorage({
				    key: 'auth',
				    success: (e) => {
						console.log("auth-success:",e)
				    },
					fail: () => {
						uni.navigateTo({
							url:'../login/login'
						})
					}
				})
			},
			p2(){
				uni.navigateTo({
					url:'/pages/my/company_accept_deliver_resume'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding: 0 30rpx 150rpx 30rpx;
	}
	.kong{
		width: 100%;
		height: 250rpx;
		opacity: 0;
	}
	page {
	  height: 100%;
	  background-color: #EDF1F2;
	}
	.boxTop{
		position: relative;
		width: 100%;
		height: 300rpx;
		background-color: #3291F8;
		display: flex;
		align-items: center;
		.box{
			margin-left: 30rpx;
			display: flex;
			align-items: center;
			image{
				width: 100rpx;
				height: 100rpx;
				display: block;
				border-radius: 50%;
				border: 4upx solid #FFFFFF;
			}
			text{
				margin-left: 30rpx;
				font-size: 48rpx;
				color: #FFFFFF;
			}
		}
		.jl{
			z-index: 999;
			width: 100%;
			position: absolute;
			top: 240rpx;
			padding: 0 30rpx;
			box-sizing: border-box;
			.jlbox{
				width: 100%;
				background-color: #ffffff;
				padding:50rpx;
				box-sizing: border-box;
				display: flex;
				align-items: flex-start;
				border-radius: 15rpx;
				.tu{
					width: 60rpx;
					height: 60rpx;
					image{
						width: 60rpx;
						height: 60rpx;
						display: block;
					}
				}
				.zi{
					text{
						display: block;
						margin-left: 30rpx;
						&:nth-child(1){
							color: #101010;
							font-size: 28rpx;
							font-weight: bolder;
							margin-bottom: 20rpx;
						}
						&:nth-child(2){
							color: #B0B0B0;
							font-size: 20rpx;
							margin-bottom: 20rpx;	
						}
						&:nth-child(3){
							width: 232rpx;
							height: 62rpx;
							color: #3291F8;
							font-size: 24rpx;
							text-align: center;
							line-height: 60rpx;
							border-radius: 100rpx;
							border: 1rpx solid #3291F8;
						}
					}
				}
			}
		}
	}
</style>
